import { Controller } from 'egg';
export default class HomeController extends Controller {

  public async create() {
    const { ctx } = this;
    const { url } = ctx.request.body;
    await ctx.model.Avatar.deleteMany({});
    await (new ctx.model.Avatar({ url })).save();
    ctx.body = await ctx.model.Avatar.findOne({});
  }

  public async find() {
    const { ctx } = this;
    ctx.body = await ctx.model.Avatar.findOne({});
  }
}
